package com.yudaob2b.elong.service;

import com.yudaob2b.elong.constant.RedisConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 * 消息生产者
 *
 * @author Kidd.Tan
 * @email 298023780@qq.com
 * @date 7/15/18 1:00 AM
 */
@Service
public class RedisPublisherService {

    @Autowired
    private StringRedisTemplate redisTemplate;

    public String sendMessage(String name) {
        try {
            redisTemplate.convertAndSend(RedisConstant.REDIS_TOPIC_INCR_INVENTORY, name);
            return "消息发送成功了";

        } catch (Exception e) {
            e.printStackTrace();
            return "消息发送失败了";
        }
    }
}
